
    # Log table Generator for Forbin LFO

maxv             = 2**32
num_out_steps    = 2**12
steps_per_octave = 400
max_osctaves     = 10
max_freq         = 100      # Hz

rxt = Array.new()

for idx in 0..num_out_steps

    stp = (idx.to_f() / num_out_steps.to_f()) * 3.141592653589793238462643383 * 2
    fcv =  2047.5 * Math.sin(stp) + 2047.5
    ifcv = (fcv + 0.5).to_i()
    
    rxt[idx] = ifcv
    
    # work back to a frequency!
    
#    afv = ( ifcv.to_f() / maxv.to_f() ) * 10000.0
    
#    printf("    .short %6x ; %6d\n", ifcv, idx)
end

#exit(0)

    # we intend to break the table into 128 entries

lrv = Array.new()
for idx in 0...128
    lrv.clear()
    sumx  = 0.0
    sumy  = 0.0
    sumxy = 0.0
    sumxx = 0.0
    sumyy = 0.0
    for nxx in 0...32
        spy   = rxt[idx * 32 + nxx].to_f()
        sumx  += nxx
        sumy  += spy
        sumxx += nxx * nxx
        sumyy += spy * spy
        sumxy += nxx * spy
        # printf("%4d %d %g %g %g %g %g\n", nxx, spy, sumx, sumy, sumxx, sumyy, sumxy)
    end
    sqx    = sumx * sumx
    sqy    = sumy * sumy
    slope  = ( (32.0 * sumxy) - (sumx * sumy) ) / (32.0 * sumxx - sqx)
    yint   = (sumy - (slope * sumx) ) / 32.0

    islope = (slope * 32 + 0.5).to_i()
    yfv    = (yint + 0.5).to_i()

    printf("     .short   %d,%d ; %g,%g\n", islope, yfv, slope, yint)

    for nxx in 0...32
        b1  = (nxx * islope) / 32
        ny  = yfv + b1
        iny = ny
        pxx = idx * 32 + nxx
        iry = rxt[pxx]
        dy  = iry - iny
        # printf("%x %d %d 0x%x 0x%x %d -> %d\n", slope, pxx, iny, iny, b1, iry, dy)
    end
    
end
